# -*- coding: utf-8 -*-
'''
Created on 06/ott/2009

@author: sax
'''
from django.template import Library

register = Library()



def class_if_errors(error_list, classname):
    """
        siplet tool to check if 
    >>> class_if_errors([{},{}],"class")
    ""
    >>> class_if_errors([{1:1},{}],"class")
    "class"
    """
    for el in error_list:
        if el != {}:
            return classname
    return ""

#def iif_collapsed( inline_admin_form, true, false ):
#    print 11111111111111111, dir( inline_admin_form.formset ), type(inline_admin_form.formset)
#    if (not inline_admin_form.form.errors) and inline_admin_form.formset.opts.collapsed:
#        return true
#    else:
#        return false
#
#iif_collapsed = register.simple_tag(iif_collapsed)    
class_if_errors = register.simple_tag(class_if_errors)